home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / XRef_Full.T < prev    next >
Encoding:
Text File  |  1993-02-08  |  2.6 KB  |  95 lines  |  [TEXT/KEEN]

  1. # XRef_Full.T (or .A): from one or more source files, build a
  2. #cross-reference list of selected top-level terms.
  3. #NOT AN EXECUTABLE FILE: this file is used only as a "Template" by
  4. #$XRef_Full, which is the one to call for full cross-referencing.
  5. #The file "Skip for XRef" below holds a list of common terms to skip over.
  6. #In large cross-reference jobs it may be NECESSARY to skip the commonest
  7. #terms to avoid overflowing the list of references. 
  8.  
  9. BEGIN {
  10.         skipfile = STDPATH "Drag_on Modules:hAWK programs:" "Skip for XRef"
  11.         while (getline < skipfile > 0)
  12.             {
  13.             for ( k = 1; k <= NF; k++)
  14.                 skipList[$k] = 1; #Forces skipList[$k] to "exist".
  15.             }
  16.         close(skipfile)
  17.         $0 = ""
  18.         progressFile = STDPATH "$tempProgress"
  19.         }
  20.  
  21. FNR == 1 {    z = split(FILENAME, names, ":")
  22.             fName[++fIndex] = names[z]
  23.             if (!progress("\nXReffing: " names[z]))
  24.                 { # concurrent mode, print progress to file
  25.                 print "XReffing:", names[z] > progressFile
  26.                 close(progressFile)
  27.                 }
  28.         }
  29.  
  30. #Strip down to words, look up term and record locations.
  31. #Only the file index is recorded - at end when printing, the index
  32. #is replaced by the proper file name.
  33.     {#gsub(/'(.)*'/, "") - uncomment this to skip single quotes
  34.     gsub(/[^A-Za-z0-9_]/, " ")
  35.     for (i = 1; i <= NF; ++i)
  36.         {
  37.         #skip if in skipList
  38.         if ($i in skipList)
  39.             continue;
  40.         type = lookup($i)
  41.         ##MARK record
  42.         #if (type == 1) #define
  43.         #        defines[$i] = defines[$i] "\t" fIndex "\t" FNR
  44.         #else if (type == 2)#variable
  45.         #        vars[$i] = vars[$i] "\t" fIndex "\t" FNR
  46.         #etc
  47.         }
  48.     }
  49.  
  50. END {
  51.     if (!progress("\nBuilding final list..."))
  52.         { # concurrent mode, print progress to file
  53.         print "Building final list..." > progressFile
  54.         close(progressFile)
  55.         }
  56.     print "Cross-reference listing:"
  57.     #build master array, for sorting all at once
  58.     ##MARK linear
  59.     #for (w in defines)
  60.     #    {
  61.     #      linear[++m] = w ": #define" defines[w]
  62.     #    delete defines[w]
  63.     #      }
  64.     #for (w in vars)
  65.     #    {
  66.     #      linear[++m] = w ": variable" vars[w]
  67.     #    delete vars[w]
  68.     #      }
  69.     #etc
  70.     if (!progress("\nSorting final list..."))
  71.         { # concurrent mode, print progress to file
  72.         print "Sorting final list..." > progressFile
  73.         close(progressFile)
  74.         }
  75.     sort(linear, ind, "d")
  76.     if (!progress("\nPrinting final list to stdout..."))
  77.         { # concurrent mode, print progress to file
  78.         print "Printing final list to stdout..." > progressFile
  79.         close(progressFile)
  80.         }
  81.      for (j = 1; j <= m; ++j)
  82.         {
  83.         r = split(linear[ind[j]], out, "\t")
  84.         print out[1]
  85.         for (t = 2; t <= r; ++t)
  86.             {#print file name from array fName, print line number
  87.             print "\t", fName[out[t]], out[++t]
  88.             }
  89.         print ""
  90.         }
  91.     if (m == 0)#nothing at all
  92.         print "No top-level terms were found."
  93.     }
  94.  
  95.